package com.xinchao.service.impl;

import com.xinchao.dao.AdvertisementMonitorMapper;
import com.xinchao.exception.ServiceException;
import com.xinchao.model.dto.AdvertisementExposuresTouchWatchSumDTO;
import com.xinchao.model.dto.AdvertisementMonitorSumDTO;
import com.xinchao.service.AdvertisementMonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author dxy
 * @date 2018/9/29 16:39
 */
@Service(value = "advertisementMonitorService")
public class AdvertisementMonitorServiceImpl implements AdvertisementMonitorService {
	@Autowired
	private AdvertisementMonitorMapper advertisementMonitorMapper;

	/**
	 * 通过时间获取广告监播总数
	 * @param advertisementName 广告名称
	 * @param startTime         开始时间
	 * @param endTime           结束时间
	 * @param deviceNumber      机器码
	 * @return IndexAdvertisementMonitorSumVO
	 * @throws ServiceException
	 */
	@Override
	public AdvertisementMonitorSumDTO getAdvertisementMonitorSumByTime(String advertisementName, Long startTime, Long endTime, String deviceNumber) throws ServiceException {
		if (startTime == null || endTime == null) {
			throw new ServiceException("输入参数不能为空");
		}
		return advertisementMonitorMapper.getAdvertisementMonitorSumByTime(advertisementName, startTime, endTime, deviceNumber);
	}

	/**
	 * 通过时间获取终端机器码列表
	 * @param startTime 开始时间
	 * @param endTime 结束时间
	 * @return Long
	 * @throws ServiceException
	 */
	@Override
	public List<String> listDeviceNumberByTime(Long startTime, Long endTime) throws ServiceException {
		if (startTime == null || endTime == null) {
			throw new ServiceException("输入参数不能为空");
		}
		return advertisementMonitorMapper.listDeviceNumberByTime(startTime, endTime);
	}

	/**
	 * 通过时间获取广告监播的曝光次数、触达人次、观看人次
	 * @param startTime 开始时间
	 * @param endTime 结束时间
	 * @return AdvertisementExposuresTouchWatchSumDTO
	 * @throws ServiceException
	 */
	@Override
	public AdvertisementExposuresTouchWatchSumDTO getAdvertisementExposuresTouchWatchSumByTime(Long startTime, Long endTime) throws ServiceException {
		if (startTime == null || endTime == null) {
			throw new ServiceException("输入参数不能为空");
		}
		return advertisementMonitorMapper.getAdvertisementExposuresTouchWatchSumByTime(startTime, endTime);
	}

	/**
	 * 获取广告监播表中的所有天数列表
	 * @return List<String>
	 */
	@Override
	public List<String> listAllDays() {
		return advertisementMonitorMapper.listAllDays();
	}

}
